﻿using System;
using System.Diagnostics.Contracts;
using Adalbertus.BudgetPlanner.Domain;
using Adalbertus.BudgetPlanner.Domain.Repositories;

namespace Adalbertus.BudgetPlanner.Services.CodeContracts
{
    [ContractClassFor(typeof(ISavingService))]
    public abstract class ISavingServiceContract : BaseService<Saving>, ISavingService
    {
        protected ISavingServiceContract(IRepositoryFactory repositoryFactory, IUnitOfWorkProvider unitOfWorkProvider)
            : base(repositoryFactory, unitOfWorkProvider)
        {
        }

        public Saving Create(string name)
        {
            Contract.Requires(!string.IsNullOrWhiteSpace(name));
            Contract.Ensures(Contract.Result<Saving>() != null);
            Contract.Ensures(Contract.Result<Saving>().Name.Equals(name));

            throw new NotImplementedException();
        }

        public SavingEntry CreateEntry(Saving saving, decimal value, DateTime date)
        {
            Contract.Requires<ArgumentNullException>(saving != null);
            Contract.Requires(value >= 0);
            Contract.Ensures(Contract.Result<SavingEntry>() != null);
            Contract.Ensures(Contract.Result<SavingEntry>().Value == value);
            Contract.Ensures(Contract.Result<SavingEntry>().Date == date);
            Contract.Ensures(Contract.Result<SavingEntry>().Saving== saving);

            throw new NotImplementedException();
        }

        public void RemoveEntry(SavingEntry entry)
        {
            Contract.Requires<ArgumentNullException>(entry != null);
            throw new NotImplementedException();
        }
    }
}
